<!DOCTYPE html>
<html>

<head>
    <title>我的消息</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/flex.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/dropload.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/accounts-child.css">
    <script type="text/javascript" src="/resource/web/js/flexible.js"></script>
    <script type="text/javascript" src="/resource/web/js/jquery-1.11.1.min.js"></script>
</head>

<body>
    <div class="mod-tit">
        <div class="title">
            <p>消息中心</p>
            <a href="/Web/user_accounts"><img class="back" src="/resource/web/img/newhead/path_7_copy.png"></a>
        </div>
        <div class="not-tab tcf-flex tcf-justify-center">
            <a href="/Web/web_message.html"><div class="my-news notred">平台公告</div></a>
            <a href="/Web/my_msg.html"><div class="my-msg ">我的消息</div></a>
        </div>
    </div>
    <div class="line linemargin"></div>
    <!-- 公告 -->
    <div class="mod-not content" style="">
        <div class="lists"></div>
    </div>
    <!-- 消息 -->
    <div class="mod-not2 content2" style="display: none;" >
        <div class="lists2" style=""></div>
    </div>
    <!-- 无消息显示 -->
    <div class="mod-not3">
        <p><img src="/resource/web/img/account/no_msg.png"></p>
    </div>
<script src="/resource/web/js/dropload.min.js"></script>
<script type="text/javascript">
    $(".not-tab>div").on("touchend",function(){
         $(this).addClass("notred").siblings().removeClass("notred");
    })
    function getLocalTime(nS) {
        var dateStr=new Date(parseInt(nS) * 1000).toLocaleDateString();
        dateStr=dateStr.replace(/年|月/g, "/").replace(/日/g,"");
        var month = (new Date(dateStr)).getMonth() + 1;
        var year = (new Date(dateStr)).getFullYear();
        var date = (new Date(dateStr)).getDate();
        if (month < 10) {
            month = '0' + month;
        }
        if (date < 10) {
            date = '0' + date;
        }
        return year+"-"+month+"-"+date;
    }

    $(".my-news").click(function(){
        $(".mod-not").show();
        $(".mod-not2").hide();
    })
    $(".my-msg").click(function(){
        $(".mod-not").hide();
        $(".mod-not2").show();
    })

    // 点击后字体的颜色改变

    $(function(){
        // 页数
        var page = 0;
        // 每页展示5个
        //var size = 10;
        // dropload
        $('.content').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                page++;
                var result = '';
                $.ajax({
                    type: 'GET',
                    processData: false,//https://www.gangpiaowang.com
                    url: '/Web/web_message.html?type=news&page='+page,
                    dataType: 'json',
                    success: function(data){
                        var arrLen = data.length;
                        var arrlist = data;
                        //console.log(arrlist);
                        //console.log(arrlist);
                        if(arrLen > 0){
                            $(".mod-not3").hide();
                            for(var i=0; i<arrLen; i++){
                                //console.log( arrlist[i] );
                                result +=   '<a href="#0"><div class="gg-list"><p class="gg-tit">'+arrlist[i].title+'</p>'
                                        +'<p class="gg-tim">'+getLocalTime(arrlist[i].add_time)+'</p></div></a>'
                            }
                            // 如果没有数据
                        }else{
                            // 锁定
                            me.lock();
                            // 无数据
                            me.noData();
                        }
                        $('.lists').append(result);
                        me.resetload();
                        // 为了测试，延迟1秒加载
                        /*setTimeout(function(){
                         // 插入数据到页面，放到最后面
                         $('.lists').append(result);
                         // 每次数据插入，必须重置
                         me.resetload();
                         },1000);*/
                    },
                    error: function(xhr, type){
                        console.log('Ajax error!');
                        // 即使加载出错，也得重置
                        me.resetload();
                    }
                });
            }
        });
    })
</script>
</body>

</html>
